package com.breaking.second.utils.compat;

import android.graphics.Color;

import androidx.recyclerview.widget.RecyclerView;

import com.littlejerk.rvdivider.builder.XLinearBuilder;
import com.littlejerk.rvdivider.builder.XStaggeredGridBuilder;

public class RecyclerCompat {
    public static void SpacesItemDecoration(RecyclerView recyclerView) {
        XStaggeredGridBuilder builder = new XStaggeredGridBuilder(recyclerView.getContext())
                //分割线间距，支持float dp 和DimenRes dp
                .setSpacing(2f)//这几个Spacing的优先级可看XGridBuilder说明
                .setVLineSpacing(8f)
                .setHLineSpacing(8f)
                //是否包括边界
                .setIncludeEdge(false)
                //是否忽略FullSpan的情况
                .setIgnoreFullSpan(true);
        recyclerView.addItemDecoration(builder.build());
    }
    public static void SpacesItemDecoration0(RecyclerView recyclerView) {
        XStaggeredGridBuilder builder = new XStaggeredGridBuilder(recyclerView.getContext())
                //分割线间距，支持float dp 和DimenRes dp
                .setSpacing(2f)//这几个Spacing的优先级可看XGridBuilder说明
                .setVLineSpacing(8f)
                .setHLineSpacing(8f)
                //是否包括边界
                .setIncludeEdge(false)
                //是否忽略FullSpan的情况
                .setIgnoreFullSpan(true);
        recyclerView.addItemDecoration(builder.build());
    }
    public static void SpacesItemDecorationHLine(RecyclerView recyclerView) {
        XLinearBuilder builder = new XLinearBuilder(recyclerView.getContext())
                //分割线间距，支持float dp 和DimenRes dp
                .setSpacing(4f)
                .setShowFirstTopLine(true)
                .setShowLastLine(true)
                .setColor(Color.TRANSPARENT)
                //设置哪几个position不绘制分割线，接受数组new int[]{0,1}，返回null表示不处理
                .setOnItemNoDivider(() -> null)
                //定制某一item分割线样式，可改颜色和设置边沿分割线，返回null表示不处理
               ;
        recyclerView.addItemDecoration(builder.build());
    }

}
